#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2025/1/11
# @Author : Joker
# @Version : Python 3.7
# @Software: PyCharm
import pymysql
import settings as conf


class DBUtil:

    @staticmethod
    def connect():
        conn = pymysql.connect(
            host=conf.DataBaseHost,
            port=conf.DataBasePort,
            user=conf.DataBaseUser,
            password=conf.DataBasePwd,
            database=conf.DataBaseName,
            charset=conf.DataBasCharset
        )
        return conn

    def execute(self, sql):
        conn = self.connect()
        cur = conn.cursor()
        cur.execute(sql)
        result = cur.fetchone()
        cur.close()
        conn.close()
        return result


dbUtil = DBUtil()
